﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using XS = System.Xml.Serialization;

namespace Nana.Bytes
{
  public static class BytesExt
  {
    private class dummyReader : XS.XmlSerializationReader
    {
      protected override void InitCallbacks()
      {
      }

      protected override void InitIDs()
      {
      }

      internal static byte[] HexToBytes(string hex)
      {
        return ToByteArrayHex(hex);
      }
    }
    private class dummyWriter : XS.XmlSerializationWriter
    {
      protected override void InitCallbacks()
      {
      }

      internal static string BytesToHex(byte[] bin)
      {
        return FromByteArrayHex(bin);
      }
    }

    public static string BytesToHex(this byte[] bin)
    {
      return dummyWriter.BytesToHex(bin);
    }
    public static byte[] HexToBytes(this string hex)
    {
      return dummyReader.HexToBytes(hex);
    }
  }
}
